/**
 * @param {number[]} nums
 * @return {void} Do not return anything, modify nums in-place instead.
 */
var moveZeroes = function (nums) {
  let len = nums.length;
  for (let i = len - 1; i >= 0; i--) {
    if (nums[i] === 0) {
      nums.splice(i, 1);
      nums.push(0);
    }
  }

  return nums;
};

let nums = [0, 1, 0, 3, 12];
let nums2 = [0, 0, 1];
console.log(moveZeroes(nums));
console.log(moveZeroes(nums2));